package com.wdb007.venus.svc.biz.qrcode.utils;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class QRCodeMain {

	public static void main(String[] args) {
		try {
//			encodeQrCode();
			merge();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	private static void merge() throws IOException {
		BufferedImage img = new BufferedImage(638, 920, BufferedImage.TYPE_INT_RGB);//创建图片
		
		BufferedImage bg = ImageIO.read(new File("E:\\git_venus\\wdb_service\\venus-service-biz\\visitor_bg.png"));
		BufferedImage qrCode = ImageIO.read(new File("E:\\git_venus\\wdb_service\\venus-service-biz\\qrcode.png"));
		
		Graphics g = img.getGraphics();//开启画图
		
		g.drawImage(bg, 0, 0, null);
		g.drawImage(qrCode, 230, 655, null);
		
		g.dispose();
		
		ImageIO.write(img, "jpg", new File("E:\\git_venus\\wdb_service\\venus-service-biz\\visitor2.jpg"));
	}

	private static void encodeQrCode() {
		String text = "https://api.wdb007.com/wdb007/appDownload.html?userid=123456";
		String iconPath = "E:\\git_venus\\wdb_service\\venus-service-biz\\icon.png"; 
		String destPath = "E:\\git_venus\\wdb_service\\venus-service-biz\\qrcode.png";
		try {
//			//生成带logo的二维码
			QRCodeUtil.encode(text, iconPath, destPath);
//			
//			//生成不带logo的二维码
//			text = "https://ws.wdb007.com/user/unlock";
//			QRCodeUtil.encode(text, destPath);
			//指定二维码图片，解析返回数据  
//			System.out.println(QRCodeUtil.decode(destPath + File.separator + "26733434.jpg"));  
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
}
